<html>
<body>
<h2>Search Results</h2>
<?php

  echo '<p>Search processed at ';
  echo date('H:i, jS F');
  echo '</p>';
  echo '<p>Your result is as follows: </p>';

  $searchitem = $_POST['searchitem'];

  if(!$searchitem)
  {
	echo "Please input search details!";
     exit;
  }
  
  if (!get_magic_quotes_gpc())
  {
     $searchitem2 = addslashes($searchitem);
  } 

  mysql_connect("localhost", "admin", "") or die(mysql_error());

  mysql_select_db("test") or die(mysql_error());

  $query= "SELECT * FROM artists WHERE aname like '%".$searchitem."%'";

  $searchresult = mysql_query($query) or die(mysql_error());  

  echo "<table border='2'>";
  echo "<tr> <th>aname</th> <th>type</th> </tr>";

// keeps getting the next row until there are no more to get

  while($row = mysql_fetch_array( $searchresult )) 
  {
	// Print out the contents of each row into a table
	echo "<tr><td>"; 
	echo $row['aname'];
	echo "</td><td>"; 
	echo $row['type'];
	echo "</td></tr>"; 
  } 

?>
</body>
</html>